package com.ty.config;

import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

/**
 * @author 天宇宇宇宇宇
 * @Data 2020/12/1 20:46
 */
public class RootConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    //获取根容器的配置类,(spring的配置文件) 父容器
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{MainConfig.class};
    }
    //获取web容器的配置类,(SpringMVC的配置文件) 子容器
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{MvcConfig.class};
    }
    //获取DispatcherServlet(前端控制器)的映射信息
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
    //解决中文乱码
    @Override
    protected Filter[] getServletFilters() {
        return new  Filter[] {new CharacterEncodingFilter("UTF-8")};
    }
}
